#include "Particle.h"
#include "modelerdraw.h"

Particle::Particle(void)
{

}

Particle::~Particle(void)
{
}

void Particle::setPosition( float x, float y, float z)
{
	position[0] = x;
    position[1] = y;
    position[2] = z;
}

void Particle::setPosition(Vec3f& pos)
{
	
	position[0] = pos[0];
	position[1] = pos[1];
	position[2] = pos[2];
}

void Particle::setVelocity( float vx, float vy, float vz )
{
    velocity[0] = vx;
    velocity[1] = vy;
    velocity[2] = vz;
}

void Particle::setVelocity(Vec3f& vel)
{
	velocity[0] = vel[0];
	velocity[1] = vel[1];
	velocity[2] = vel[2];
}

void Particle::setMass( float m )
{
    mass = m;
}

void Particle::setAge(int a, int limit)
{
	age = a;
	ageLimit = limit;
}

bool Particle::checkLife(void)
{
	age++;
	return(age >= ageLimit);
}

void Particle::setRandomMass(int min, int max) {
    int randN = rand() % max + min;
    mass = randN/10.0;
}

float Particle::getMass() const {
    return mass;
}

void Particle::setRandomSize(int min, int max)
{
    /* generate random number (20-60): */
    int randN = rand() % max + min;
    size = randN/10.0;
    //std::cout << "size: " << size << std::endl;
}

void Particle::setSize(float r)
{
	size = r;
}

void Particle::addForce( float fx, float fy, float fz )
{
    force[0] += fx;
    force[1] += fy;
    force[2] += fz;
}

void Particle::resetForce() {
    force[0] = 0.0;
    force[1] = 0.0;
    force[2] = 0.0;
}

Vec3f Particle::getForce() const {
    return force;
}

Vec3f Particle::getPosition() const {
	return position;
}

Vec3f Particle::getVelocity() const {
	return velocity;
}

void Particle::draw() {   
	glPushMatrix();
	glTranslatef(position[0], position[1], 0.0); //ignore Z axis
	drawSphere(size);
	glPopMatrix();
}